<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let arr = [1, 2, 3, 4, 5,6,7,8,9]
    function randomSort(array) {
      var n




      // for (let point = array.length -1; point >= 0; point--) {
      //   n = arr[point]
      //   let randomIndex = Math.floor(Math.random()*(array.length))
      //   arr[point]=arr[randomIndex]
      //   arr[randomIndex] = n
      //   console.log(array);
        
      // }
      for (let point = array.length -1; point >= 0; point--) {
        let randomIndex = Math.floor(Math.random()*(array.length))
        // n = arr[randomIndex]
        // arr[randomIndex] = arr[point]
        // arr[point] = n  
        n = arr[point]
        arr[point]=arr[randomIndex]
        arr[randomIndex] = n
        console.log(array);
        
      }
      return array
    }
    console.log(randomSort(arr));
    
  </script>
</body>

</html>